<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <!-- 避免IE使用兼容模式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" type="text/css"
          href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/bootstrap.min.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/animate.css/animate.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/font-awesome/css/font-awesome.css')) ?>">
    <link rel="stylesheet"
          href="<?php xcho(loadSource('/assets/plugins/data-table/media/css/dataTables.bootstrap.min.css')) ?>">
<!--    <link rel="stylesheet" href="--><?php //xcho(loadSource('/assets/plugins/ztree/css/zTreeStyle/zTreeStyle.css')) ?><!--">-->
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/layui/css/layui.css')) ?>" media="all">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/ztree/css/zTreeStyle/zTreeStyle.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/ztree/css/metroStyle/metroStyle.css')) ?>" type="text/css">
    <link rel="stylesheet" href="<?php xcho(loadSource('/app/css/style.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/app/css/app.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/css/new_main.css')) ?>">
</head>
<body><?php include_once TPL_PATH . 'public/nav.phtml'; ?>
   
    <div class="class-box">
        <div class="class-box-head">
            <div class="class-box-title">
                <h3 class="col-md-8">模板列表页面</h3>
                <div class="input-group col-md-4">
                    <input type="text" placeholder="搜索" name="title" class="form-control" value="<?php xcho($search['title']) ?>" />
                </div>
            </div>
        </div>
        <div class="class-box-body">
            <form method="get" action="<?php xcho(url('/sysmanager/sms/index')) ?>">
                <div class="col-xs-6 col-sm-3 form-container form-inline form-container-noborder">
                    <div class="form-group">
                        <label>范围：</label>
                        <select class="form-control" name="create_id">
                            <option value="">所有模板</option>
                            <option value="<?php xcho($user_id) ?>" <?php if($user_id==$search['create_id']) { ?> selected="selected" <?php } ?> >我创建的模板</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>修改日期：</label>
                        <select class="form-control" name="edit_time">
                           <option  value="">请选择</option>
                            <?php foreach ($dateT as $v) { ?>
                            <option value="<?php xcho($v['dict_value']) ?>" <?php if($search['edit_time']==$v['dict_value']) { ?> selected="selected" <?php } ?> ><?php xcho($v['cn_name']) ?></option>
                            <?php } ?>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>开始时间：</label>
                        <input class="form-control" type="date" name="edit_time_start" value="<?php xcho($search['edit_time_start']) ?>" />
                    </div>
                    <div class="form-group">
                        <label>截止时间：</label>
                        <input class="form-control" type="date" name="edit_time_end" value="<?php xcho($search['edit_time_end']) ?>" />
                    </div>
                </div>
                <div class="col-xs-6 col-sm-3 form-container form-inline">
                    <div class="form-group">
                        <label>创建日期：</label>
                        <select class="form-control" name="add_time">
                            <option  value="">请选择</option>
                            <?php foreach ($dateT as $v) { ?>
                                <option value="<?php xcho($v['dict_value']) ?>" <?php if($search['add_time']==$v['dict_value']) { ?> selected="selected" <?php } ?> ><?php xcho($v['cn_name']) ?></option>
                            <?php } ?>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>开始时间：</label>
                        <input class="form-control" type="date" name="add_time_start" value="<?php xcho($search['add_time_start']) ?>" />
                        <label>截止时间：</label>
                        <input class="form-control" type="date" name="add_time_end" value="<?php xcho($search['add_time_end']) ?>" />
                    </div>
                <div class="btns-group">
                    <button class="btn btn-primary" name="btn_search" type="submit">搜索</button>
                </div>
            </form>
        </div>
        </div>
    </div>

    <div class="class-box">
        <div class="class-box-head">
            <div class="class-box-title">
                <h3>模板列表</h3>
                <div class="class-box-tools">
                    <a class="btn btn-primary" href="<?php xcho(url('/sysmanager/Sms/add_mould')) ?>">添加模板</a>
                </div>
            </div>
        </div>
        <div class="class-box-body">
            <table style="table-layout:fixed" class="layui-form table table-bordered table-hover table table-bordered table-striped">
                <tr>
                    <th style="width: 60px;">
                        <div id="checkAll"><input lay-filter="allChoose" type="checkbox" lay-skin="primary"
                                                  name="checkAll"></div>
                    </th>
                    <th>主题</th>
                    <th>内容</th>
                    <th>创建人</th>
                    <th>编辑时间</th>
                    <th>创建时间</th>
                    <th style="width: 120px;">操作</th>
                </tr>
            <?php foreach ($list as $v) { ?>
                <tr>
                    <td><input type="checkbox" lay-filter="itemChoose" name="ck"
                               lay-skin="primary" id="<?php xcho($v['id']) ?>"></td>
                    <td >
                    <a href="<?php xcho(url('/sysmanager/sms/mouldDetail')) ?>?id=<?php xcho($v['id']) ?>"><p class="ellipsis"><?php xcho($v['title']) ?></p></a>
                    </td>
                    <td><p class="ellipsis"><?php xcho($v['message']) ?></p></td>
                    <td><?php xcho($v['create_id_name']) ?></td>
                    <td><?php xcho(date('Y-m-d H:i:s',$v['edit_time'])) ?></td>
                    <td><?php xcho(date('Y-m-d H:i:s',$v['add_time'])) ?></td>
                    <td>
                        <a class="btn btn-primary" href="<?php xcho(url('/sysmanager/sms/edit')) ?>?id=<?php xcho($v['id']) ?>">编辑</a>
                        <a class="btn btn-sub"  class="del_mould"  mid="<?php xcho($v['id']) ?>">删除</a></td>
                </tr>
            <?php } ?>
            </table>
            <form method="post" action="<?php xcho(url('/sysmanager/sms/index')) ?>">
                <div class="pages">
                    <div class="pages-group">

                        
                    </div>
                </div>

                <div class="row pagination-wrap">
                    <div class="col-sm-6">
                        
                        <div class="pagination-group col-sm-12">
                            <input class="form-control" type="number" min="1" max="<?php xcho($maxPage) ?>" name="pagelist" placeholder="请输入页码" value="<?php xcho($pageList) ?>" />
                            <input class="btn btn-primary" type="submit" value="跳转" />
                                <span>共搜索到<?php xcho($total) ?>条记录</span>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <?php xchoHtml($list->render()) ?>
                    </div>
                </div>
                

            </form>
        </div>
    </div>
<input type="hidden" name="delmould" value="<?php xcho($delmould) ?>" />
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<script src="<?php xcho(loadSource('/assets/plugins/jquery/jquery.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/data-table/media/js/jquery.dataTables.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/data-table/media/js/dataTables.bootstrap.min.js')) ?>"></script>
<script
        src="<?php xcho(loadSource('/assets/plugins/data-table/extensions/Responsive/js/dataTables.responsive.min.js')) ?>"></script>
<script
        src="<?php xcho(loadSource('/assets/plugins/data-table/extensions/Responsive/js/responsive.bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.core.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/layui/layui.all.js')) ?>" charset="utf-8"></script>
<script type="text/javascript" src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.excheck.js')) ?>"></script>
<script type="text/javascript" src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.exedit.js')) ?>"></script>
<script>
    layui.use(['form'], function(){
        var form = layui.form;
        form.on('checkbox(allChoose)', function (data) {
            var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
            child.each(function (index, item) {
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });
        form.on('checkbox(itemChoose)', function (data) {
            var sib = $(data.elem).parents('table').find('tbody input[type="checkbox"]:checked').length;
            var total = $(data.elem).parents('table').find('tbody input[type="checkbox"]').length;
            if (sib == total) {
                $(data.elem).parents('table').find('thead input[type="checkbox"]').prop("checked", true);
                form.render();
            } else {
                $(data.elem).parents('table').find('thead input[type="checkbox"]').prop("checked", false);
                form.render();
            }
        });
    });
    $(function () {
        $(".del_mould").click(function () {
            if(confirm('确定删除该模板?')){
                var url=$("input[name='delmould']").val();
                var id=$(this).attr("mid");
                if(id==null||id==''){
                    alert('请重新选择');
                    return false;
                }
                $.ajax({
                    url:url,
                    type:'post',
                    dataType:'json',
                    data:{id:id},
                    success:function (resp) {
                        if(resp.success==1){
                            alert('删除成功');
                            location.href = "/sysmanager/sms/index";
                        }else {
                            alert('删除失败');
                            location.href = "/sysmanager/sms/index";
                        }
                    }
                });
            }


        });
    });
</script>
    <?php include_once TPL_PATH . 'public/foot_script.phtml'; ?>
<button id="top" style="height: 50px;width: 50px;"></button></body>
</html>